home *** CD-ROM | disk | FTP | other *** search
/ Aminet 34 / Aminet 34 (2000)(Schatztruhe)[!][Dec 1999].iso / Aminet / util / gnu / unixcmds.lha / unixcmds / src / grep-2.1 / system.h < prev   
Encoding:
C/C++ Source or Header  |  1999-10-06  |  3.9 KB  |  163 lines

  1. /* Portability cruft.  Include after config.h and sys/types.h.
  2.    Copyright (C) 1996 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  17.    02111-1307, USA.  */
  18.  
  19. #undef PARAMS
  20. #if __STDC__
  21. typedef void *ptr_t;
  22. #define PARAMS(x) x
  23. #else
  24. typedef char *ptr_t;
  25. #define PARAMS(x) ()
  26. #endif
  27.  
  28. #define valloc system_valloc /* kludge */
  29. #ifdef HAVE_UNISTD_H
  30. # include <fcntl.h>
  31. # include <unistd.h>
  32. #else
  33. # define O_RDONLY 0
  34. int open(), read(), close();
  35. #endif
  36.  
  37. /* Some operating systems treat text and binary files differently.  */
  38. #if defined(O_BINARY) && O_BINARY
  39. # include <io.h>
  40. # ifdef __DJGPP__
  41. #  define SET_BINARY(fd)  setmode(fd,O_BINARY)
  42. # else
  43. #  define SET_BINARY(fd)  _setmode(fd,O_BINARY)
  44. # endif
  45. static inline int undossify_input PARAMS((char *, size_t));
  46. #else
  47. # ifndef O_BINARY
  48. #  define O_BINARY 0
  49. #  define SET_BINARY(fd)   (void)0
  50. # endif
  51. #endif
  52.  
  53. #if STAT_MACROS_BROKEN
  54. # undef S_ISDIR
  55. #endif
  56. #if !defined(S_ISDIR) && defined(S_IFDIR)
  57. # define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR)
  58. #endif
  59.  
  60. #ifdef STDC_HEADERS
  61. # include <stdlib.h>
  62. #else
  63. ptr_t malloc(), realloc(), calloc();
  64. void free();
  65. #endif
  66.  
  67. /* Be careful declaring valloc.  OSF/1 3.2 declares it in stdlib.h,
  68.    BSD/OS 2.1 in unistd.h.  Ultrix 4.4 doesn't declare it.  */
  69. #undef valloc /* undo the kludge */
  70. #if !defined(HAVE_VALLOC)
  71. # define valloc malloc
  72. #else
  73. ptr_t valloc();
  74. #endif
  75.  
  76. #if __STDC__
  77. # include <stddef.h>
  78. #endif
  79. #ifdef STDC_HEADERS
  80. # include <limits.h>
  81. #endif
  82. #ifndef INT_MAX
  83. # define INT_MAX 2147483647
  84. #endif
  85. #ifndef UCHAR_MAX
  86. # define UCHAR_MAX 255
  87. #endif
  88.  
  89. #if !defined(STDC_HEADERS) && defined(HAVE_STRING_H) && defined(HAVE_MEMORY_H)
  90. # include <memory.h>
  91. #endif
  92. #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
  93. # include <string.h>
  94. #else
  95. # include <strings.h>
  96. # undef strchr
  97. # define strchr index
  98. # undef strrchr
  99. # define strrchr rindex
  100. # undef memcpy
  101. # define memcpy(d, s, n) bcopy((s), (d), (n))
  102. #endif
  103. #ifndef HAVE_MEMCHR
  104. ptr_t memchr();
  105. #endif
  106.  
  107. #include <errno.h>
  108. #ifndef errno
  109. extern int errno;
  110. #endif
  111.  
  112. #ifndef HAVE_STRERROR
  113. extern int sys_nerr;
  114. extern char *sys_errlist[];
  115. # define strerror(E) ((E) < sys_nerr ? sys_errlist[(E)] : "bogus error number")
  116. #endif
  117.  
  118. #include <ctype.h>
  119.  
  120. #ifndef isgraph
  121. # define isgraph(C) (isprint(C) && !isspace(C))
  122. #endif
  123.  
  124. #ifdef isascii
  125. # define ISALPHA(C) (isascii(C) && isalpha(C))
  126. # define ISUPPER(C) (isascii(C) && isupper(C))
  127. # define ISLOWER(C) (isascii(C) && islower(C))
  128. # define ISDIGIT(C) (isascii(C) && isdigit(C))
  129. # define ISXDIGIT(C) (isascii(C) && isxdigit(C))
  130. # define ISSPACE(C) (isascii(C) && isspace(C))
  131. # define ISPUNCT(C) (isascii(C) && ispunct(C))
  132. # define ISALNUM(C) (isascii(C) && isalnum(C))
  133. # define ISPRINT(C) (isascii(C) && isprint(C))
  134. # define ISGRAPH(C) (isascii(C) && isgraph(C))
  135. # define ISCNTRL(C) (isascii(C) && iscntrl(C))
  136. #else
  137. # define ISALPHA(C) isalpha(C)
  138. # define ISUPPER(C) isupper(C)
  139. # define ISLOWER(C) islower(C)
  140. # define ISDIGIT(C) isdigit(C)
  141. # define ISXDIGIT(C) isxdigit(C)
  142. # define ISSPACE(C) isspace(C)
  143. # define ISPUNCT(C) ispunct(C)
  144. # define ISALNUM(C) isalnum(C)
  145. # define ISPRINT(C) isprint(C)
  146. # define ISGRAPH(C) isgraph(C)
  147. # define ISCNTRL(C) iscntrl(C)
  148. #endif
  149.  
  150. #define TOLOWER(C) (ISUPPER(C) ? tolower(C) : (C))
  151.  
  152. #if ENABLE_NLS
  153. # include <libintl.h>
  154. # define _(String) gettext (String)
  155. #else
  156. # define _(String) String
  157. #endif
  158. #define N_(String) String
  159.  
  160. #if HAVE_SETLOCALE
  161. # include <locale.h>
  162. #endif
  163.